<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>测试放大镜</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box {
            margin: 100px;
            width: 350px;
            height: 350px;
            border: 1px gray solid;
            position: relative;
        }

        .box>.small>.shadow {
            position: absolute;
            top: 0;
            left: 0;
            width: 100px;
            height: 100px;
            display: none;
            /* 鼠标形状移动 */
            cursor: move;
            background-color: rgba(255, 255, 0, 0.3);

        }

        .box>.big {
            display: none;
            position: absolute;
            top: 0;
            left: 360px;
            width: 400px;
            height: 400px;
            border: 1px solid #000000;
            /* 超出部分隐藏 */
            overflow: hidden;
        }

        .box>.big>.bigImg {
            position: absolute;
            top: 0;
            left: 0;
            width: 1600px;
            height: 1600px;
        }
    </style>
</head>

<body>
    <div class="box">
        <div class="small">
            <img src="./001.jpg" alt="小图">
            <span class="shadow"></span>
        </div>
        <div class="big">
            <img class="bigImg" src="./0001.jpg" alt="大图">
        </div>
    </div>
</body>
<script>
        var box = document.querySelector('.box')
    var small = document.querySelector('.small')
    var shadow = document.querySelector('.shadow')
    var big = document.querySelector('.big')
    var bigImg = document.querySelector('.bigImg')

    // 鼠标经过小盒子，让 遮罩层，和 big 显示
    small.onmouseover = function () {
        console.log('aaa');
        shadow.style.display = 'block'
        big.style.display = 'block'
    }
       // 鼠标离开小盒子，让 遮罩层，和 big 隐藏
       small.onmouseout = function () {
        shadow.style.display = 'none'
        big.style.display = 'none'
    }

</script>
</html>